package com.snake.win.obj;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class GameObj {

    Sprite sprite;
    //坐标
    public int snake_x;
    public int snake_y;

    boolean moveOK;

    public int G = 0;
    public int H = 0;

    public GameObj father;

    public GameObj() {
    }

    public GameObj(int x, int y) {
        snake_x = x;
        snake_y = y;
    }

    public GameObj(Texture image, int x, int y) {
        this.snake_x = x;
        this.snake_y = y;
        this.moveOK = true;
        sprite = new Sprite(image);
        sprite.setPosition(x, y);
        sprite.setSize(1, 1);
    }

    @Override
    public String toString() {
        // TODO Auto-generated method stub
        return snake_x + "-" + snake_y;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj instanceof GameObj) {
            GameObj gameObj = (GameObj) obj;
            return this.snake_x == gameObj.snake_x && this.snake_y == gameObj.snake_y;
        }
        return false;
    }

    //绘制自身
    public void paintSelf(SpriteBatch g) {
        sprite.draw(g);
    }
}
